package express.bttree;

public class Utils {
    public static boolean comparable(Object v1, Object v2) {
        if(v1 instanceof Boolean && v2 instanceof Boolean) {
            return true;
        }
        if((v1 instanceof Integer || v1 instanceof Long) && (v2 instanceof Integer || v2 instanceof Long)) {
            return true;
        }
        if(v1 instanceof String && v2 instanceof String) {
            return true;
        }
        return false;
    }

    public static boolean isOp(String str) {
        Operator operator = getOperator(str);
        if(operator == null) {
            return false;
        } else {
            return true;
        }
    }

    public static Operator getOperator(String op) {
        switch (op) {
            case "=":
            case "==":
                return Operator.eq;
            case ">":
                return Operator.gt;
            case ">=":
                return Operator.gte;
            case "<":
                return Operator.lt;
            case "<=":
                return Operator.lte;
            case "<>":
            case "!=":
                return Operator.ne;
            default:
                return null;
        }
    }
}
